﻿#ifndef LOTTIEPLAYER_H
#define LOTTIEPLAYER_H

#include <QMainWindow>

#include "qtlottiewidget.h"

QT_BEGIN_NAMESPACE
namespace Ui { class LottiePlayer; }
QT_END_NAMESPACE

class LottiePlayer : public QMainWindow
{
    Q_OBJECT
public:
    LottiePlayer(QWidget *parent = nullptr);
    ~LottiePlayer();
    void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
    void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
private slots:
    void on_horizontalSlider_pos_valueChanged(int value);
    void on_comboBox_speed_currentTextChanged(const QString &text);
    void on_pushButton_play_clicked();
    void on_pushButton_pause_clicked();
    void on_pushButton_stop_clicked();
    void on_pushButton_load_clicked();
    void on_pushButton_gif_clicked();
    void on_pushButton_loop_toggled(bool checked);
    void on_pushButton_reverse_toggled(bool checked);
    void on_pushButton_fullscreen_toggled(bool checked);
private:
    QString formatTime(int ms);
    void initLoaded(const QString& name);
    void loadShowDlg(bool fileMode);
    void saveScreenshot(QImage img, bool saveFile);
    bool eventFilter(QObject *watched, QEvent *event) override;
private:
    Ui::LottiePlayer *ui;
    QString m_allTime = 0;
    int m_allFrame = 0;
    bool m_showFullscreen = false;
    QtLottieWidget* m_lottieWidget{};
    QString m_statusText;
};
#endif // LOTTIEPLAYER_H
